package com.bainuo.doctor.common.base;

import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import java.util.List;

/**
 * 快速试用adapter
 * 适用于快速开发单一列表viewType
 *
 * @param <T>
 */
public abstract class NormalAdapter<T> extends RecyclerView.Adapter<NormalViewHolder> {

    private List<T> mDatas;

    public NormalAdapter(List<T> datas) {
        this.mDatas = datas;
    }

    public abstract int getLayoutId(int viewType);

    @Override
    public NormalViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return NormalViewHolder.get(parent, getLayoutId(viewType));
    }

    @Override
    public void onBindViewHolder(NormalViewHolder holder, int position) {
        convert(holder, mDatas.get(position), position);
    }

    @Override
    public int getItemCount() {
        return mDatas.size();
    }

    public abstract void convert(NormalViewHolder holder, T data, int position);


}
